/*
** my_itos.c for libmy in /home/goupil_r//Tek2Ed/minitalk/src
**
** Made by robin goupil
** Login   <goupil_r@epitech.net>
**
** Started on  Wed Nov 14 15:36:02 2012 robin goupil
** Last update Sat Nov 17 10:14:59 2012 robin goupil
*/

#include "my.h"

char		*my_itos(long nbr)
{
  int		size;
  long		cpy;
  int		i;
  char		*out;

  size = 0;
  cpy = nbr > 0 ? nbr : nbr * -1;
  while (cpy > 0)
    {
      size++;
      cpy = cpy / 10;
    }
  out = xmalloc(size + 2);
  i = 1;
  if (nbr < 0)
    out[0] = '-';
  while (nbr > 0)
    {
      out[size - i++] = (nbr % 10) + 48;
      nbr = nbr / 10;
    }
  return (out);
}
